from django.contrib import admin
from DashBoard.models import *

# # Register your models here.
admin.site.site_header = '芳香之城'
admin.site.site_title = '数据可视化平台'

@admin.register(GeoInfo) # 第一个参数可以是列表
class GeoInfoAdmin(admin.ModelAdmin):
    list_display = ('name', 'longitude', 'latitude', 'elevation', 'address', 'status', 'tips', 'createtime', 'updatetime')
    list_per_page = 20
  
    ordering = ('status',)
 
    list_editable = ['status']
 
    # fk_fields = ('publish_id',)
 
    list_display_links = ("address",'name')

@admin.register(Mileage)
class MileageAdmin(admin.ModelAdmin):
    list_display = ('name', 'startpoint', 'destination', 'mileage', 'status', 'tips', 'createtime', 'updatetime')
    list_per_page = 20
    ordering = ('mileage',)
    list_editable = ['mileage', 'status']
    fk_fields = ('startpoint_name',)

@admin.register(DataInfo)
class DataInfoAdmin(admin.ModelAdmin):
    list_display = ('place', 'name', 'data', 'unit', 'status', 'tips', 'createtime', 'updatetime')
    list_per_page = 20
    ordering = ('updatetime',)
    list_editable = ['data', 'status', 'unit']
    fk_fields = ('place.name', 'name.pid')

@admin.register(CateInfo)
class CateInfoAdmin(admin.ModelAdmin):
    list_display = ('name', 'pid', 'grade')
    list_per_page = 20
    ordering = ('name',)
    list_editable = ['grade', 'pid']